package ch.zhaw.swp1.model.message.body;

import java.util.List;

import ch.zhaw.swp1.model.status.Status;
import ch.zhaw.swp1.model.status.error.MessageLengthError;

/**
 * Generic class representing an SMS body
 * @author Daniel Tiefenauer
 *
 */
public class SMSBody extends Body {

	/**
	 * Default version
	 */
	private static final long serialVersionUID = 1L;
	private static final int maxCharacters = 480;

	/************************************************************************************/
	/* Constructors
	/*----------------------------------------------------------------------------------*/
	/**
	 * Default Constructor
	 */
	public SMSBody(){
		super();
	}
	
	/**
	 * Constructor with params
	 * @param messageText user entered message text
	 */
	public SMSBody(String messageText) {
		super(messageText);
	}

	/************************************************************************************/
	/* START validation
	/*----------------------------------------------------------------------------------*/
	/**
	 * Validate SMS body
	 */
	@Override
	public List<Status> validate() {
		super.validate();
		validateTextLength();
		return statusList;
	}
	
	/**
	 * Validate length of SMS message text
	 */
	private void validateTextLength(){
		if (messageText.length() > maxCharacters){
			statusList.add(new MessageLengthError(messageText.length(), maxCharacters));
		}
	}
	/*----------------------------------------------------------------------------------*/
	/* END validation
	/************************************************************************************/


}
